package com.kefu.chat.vo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.chat.model.ChatChannelSideBar;
import com.kefu.common.vo.AbstractSearchVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;

@Data
public class ChatChannelSideBarSearchVo extends AbstractSearchVo {
    @NotEmpty
    @ApiModelProperty(value = "渠道id")
    private String channelId;

    private String menuName;

    @Override
    public LambdaQueryWrapper<ChatChannelSideBar> lambdaQuery() {
        LambdaQueryWrapper<ChatChannelSideBar> wrapper = Wrappers.lambdaQuery(ChatChannelSideBar.class);
        wrapper.eq(ChatChannelSideBar::getChannelId, channelId);
        if (StrUtil.isNotBlank(menuName)) {
            wrapper.like(ChatChannelSideBar::getMenuName, menuName);
        }
        wrapper.orderByAsc(ChatChannelSideBar::getSortNo);
        return wrapper;
    }
}
